<?php defined('SYSPATH') or die();?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>景点添加/修改</title>
    {template 'stourtravel/public/public_min_js'}
    {php echo Common::getCss('style.css,base.css,base_new.css,../js/jqueryui/jquery-ui.min.css'); }
    {php echo Common::getScript('config.js,calendarprice/calendar-price.js,xmselect/xmselect.js');}
    {php echo Common::getScript("uploadify/jquery.uploadify.min.js,choose.js,product_add.js,imageup.js,jquery.validate.js,template.js,st_validate.js,jqueryui/jquery-ui.min.js,jquery.upload.js"); }
    {php echo Common::getCss('uploadify.css','js/uploadify/'); }
    {php echo Common::getCss('calendar-price.css','js/calendarprice/'); }
    {Common::css_plugin('spot_edit.css','spot')}
</head>
<body>
	<table class="content-tab" bottom_margin=JwQrqt >
        <tr>
            <td width="119px" class="content-lt-td"  valign="top">
                {template 'stourtravel/public/leftnav'}
                <!--右侧内容区-->
            </td>
            <td valign="top" class="content-rt-td">
                <form method="post" name="product_frm" id="product_frm">
                    <div class="cfg-header-bar" style="position: fixed;width: 94%;z-index: 99999">
                        <div class="cfg-header-tab" id="nav">
                            <span class="item on">产品信息</span>
                            {if $info['id']}
                            <span class="item" data-id="price_con">价格/库存</span>
                            {/if}
                            <span class="item" data-id="other_info">其他信息</span>
                        </div>
                        {if $info['id']}
                        <a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10" onclick="window.location.reload()">刷新</a>
                        {/if}
                    </div>
                    <!--基础信息开始-->
                    <div class="product-add-div mt-40">
                        <ul class="info-item-block">
                            <li>
                              <span class="item-hd item-title">基本信息</span>
                            </li>
                            <li>
                                <span class="item-hd">站点{Common::get_help_icon('product_site')}：</span>
                                <div class="item-bd">
                                  <span class="select-box w200">
                                      <select class="select" name="webid">
                                          <option value="0" {if $info['webid']==0}selected="selected"{/if}>主站</option>
                                          {loop $weblist $k}
                                            <option value="{$k['webid']}" {if $info['webid']==$k['webid']}selected="selected"{/if} >{$k['webname']}</option>
                                          {/loop}
                                      </select>
                                  </span>
                                </div>
                            </li>
                            <li>
                                <span class="item-hd"><i class="c-red">*</i>景点名称{Common::get_help_icon('product_title')}：</span>
                                <div class="item-bd">
                                    <input type="text" name="title" id="spotname" class="input-text w800" value="{$info['title']}"/>
                                </div>
                            </li>
                            <li>
                              <span class="item-hd">景点简称{Common::get_help_icon('product_spot_shortname')}：</span>
                                <div class="item-bd">
                                    <input type="text" name="shortname" id="shortname" class="input-text w800" value="{$info['shortname']}"/>
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">景点卖点{Common::get_help_icon('product_sellpoint')}：</span>
                                <div class="item-bd">
                                    <input type="sellpoint" name="sellpoint" id="sellpoint" class="input-text w800" value="{$info['sellpoint']}"/>
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">开放时间{Common::get_help_icon('product_spot_open_time')}：</span>
                                <div class="item-bd">
                                  <input type="text" name="open_time_des"  class="input-text w800" value="{$info['open_time_des']}" />
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">咨询电话：</span>
                                <div class="item-bd">
                                    <input type="text" name="telephone" class="input-text" style="width: 364px" value="{$info['telephone']}"/>
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">目的地选择{Common::get_help_icon('product_destination')}：</span>
                                <div class="item-bd">
                                    <a href="javascript:;" class="fl btn btn-primary radius size-S mt-5" onclick="Product.getDest(this,'.dest-sel',5)"  title="选择">选择</a>
                                    <div class="save-value-div mt-2 ml-10 dest-sel w700">
                                        {loop $info['kindlist_arr'] $k $v}
                                        <span class="mb-5 {if $info['finaldestid']==$v['id']}finaldest{/if}" title="{if $info['finaldestid']==$v['id']}最终目的地{/if}" ><s onclick="$(this).parent('span').remove()"></s>{$v['kindname']}<input type="hidden" class="lk" name="kindlist[]" value="{$v['id']}"/>
                                           {if $info['finaldestid']==$v['id']}<input type="hidden" class="fk" name="finaldestid" value="{$info['finaldestid']}"/>{/if}</span>
                                        {/loop}
                                    </div>
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">景点地址{Common::get_help_icon('product_spot_address')}：</span>
                                <div class="item-bd">
                                    <input type="text" name="address" id="address" class="input-text w800" value="{$info['address']}" />
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">景点坐标{Common::get_help_icon('product_spot_address_lbs')}：</span>
                                <div class="item-bd">
                                    <div>
                                        <span class="item-text w60">经度(Lng):</span>
                                        <input type="text" name="lng" id="lng"  class="input-text w300" value="{$info['lng']}" />
                                    </div>
                                    <div class="mt-10">
                                        <span class="item-text w60">纬度(Lat):</span>
                                        <input type="text" name="lat" id="lat" class="input-text w300" value="{$info['lat']}"  />
                                        <a href="javascript:;" class="btn btn-primary radius size-S ml-10" onclick="Product.Coordinates(700,500)"  title="选择">选择</a>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">景点属性{Common::get_help_icon('product_attr')}：</span>
                                <div class="item-bd">
                                    <a href="javascript:;" class="fl btn btn-primary radius size-S mt-5" onclick="Product.getAttrid(this,'.attr-sel',5)"  title="选择">选择</a>
                                    <div class="save-value-div mt-2 ml-10 attr-sel w700">
                                        {loop $info['attrlist_arr'] $k $v}
                                        <span class="mb-5"><s onclick="$(this).parent('span').remove()"></s>{$v['attrname']}<input type="hidden" name="attrlist[]" value="{$v['id']}"></span>
                                        {/loop}
                                    </div>
                                </div>
                            </li>
                        </ul>
                        <div class="line"></div>
                        <ul class="info-item-block">
                            <li>
                                <span class="item-hd item-title">产品图片{Common::get_help_icon('product_images')}</span>
                                <div class="item-bd">
                                    <div class="lh-24 mt-3 c-f60">首图为第一张，支持鼠标拖拽调整图片顺序，支持上传1-20张图片</div>
                                    <div class="">
                                        <div id="pic_btn" class="btn btn-primary radius size-S mt-3">上传图片</div>
                                        <span class="item-text c-999 ml-10">建议上传尺寸 PC1024*695px UNIAPP750*750px</span>
                                    </div>
                                    <div class="up-list-div">

                                        <input type="hidden" class="headimgindex" name="imgheadindex" value=""/>
                                        <input type="hidden" name="litpic" id="litpic" value="{$info['litpic']}"/>
                                        <ul class="pic-sel">

                                        </ul>
                                        <script>
                                            $(".pic-sel").sortable();
                                        </script>
                                    </div>
                                </div>
                            </li>

                            {template 'stourtravel/public/upload_img'}
                        </ul>
                        <div class="line"></div>
                        <ul class="info-item-block">
                            <li>
                                <span class="item-hd item-title">产品视频{Common::get_help_icon('product_video')}</span>
                                <div class="item-bd">
                                    <div class="">
                                        <span class="item-text c-f60">最多可上传1个视频，视频需小于15M,限MP4格式</span>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <span class="item-hd"></span>
                                <div class="item-bd">
                                    <div class="mt-3">
                                        <a href="javascript:;" class="btn btn-primary radius size-S" id="uploadVideo">上传视频</a>
                                        <span class="item-text ml-10 c-999">视频大小不超过2M</span>
                                    </div>
                                    <ul class="up-video-list" id="videoContent">
                                        {if $info['product_video']}
                                        {php}list(,$videoName)=explode('|',$info['product_video']){/php}
                                        <li><input name="product_video" type="hidden" value="{$info['product_video']}"><span class="v-name">{$videoName}</span><a href="javascript:;" class="btn-link ml-20" onclick="videoNode()">删除</a></li>
                                        {/if}
                                    </ul>
                                </div>
                            </li>
                        </ul>
                        <div class="line"></div>
                        <ul class="info-item-block">
                            <li>
                                <span class="item-hd item-title">积分策略</span>
                                <div class="item-bd">
                                    <div class="">
                                        <span class="item-text c-f60"> 未选择的情况下默认使用全局策略</span>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">预订送分策略{Common::get_help_icon('product_integral_strategy')}：</span>
                                <div class="item-bd">
                                    <a href="javascript:;" class="fl btn btn-primary radius size-S mt-5" onclick="Product.getJifenbook(this,'.jifenbook-sel',5)" title="选择">选择</a>
                                    <div class="save-value-div mt-2 ml-10 jifenbook-sel">
                                        {if !empty($info['jifenbook_info'])}
                                        <span><s onclick="$(this).parent('span').remove()"></s>{$info['jifenbook_info']['title']}({$info['jifenbook_info']['value']}{if $info['jifenbook_info']['rewardway']==1}%{/if}积分)
                                        {if $info['jifenbook_info']['isopen']==0}<a class="cor_f00">[已关闭]</a>{/if}<input type="hidden" name="jifenbook_id" value="{$info['jifenbook_info']['id']}">
                                    </span>
                                        {/if}
                                    </div>
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">积分抵现策略{Common::get_help_icon('product_integral_strategy')}：</span>
                                <div class="item-bd">
                                    <a href="javascript:;" class="fl btn btn-primary radius size-S mt-5" onclick="Product.getJifentprice(this,'.jifentprice-sel',5)" title="选择">选择</a>
                                    <div class="save-value-div mt-2 ml-10 jifentprice-sel">
                                        {if !empty($info['jifentprice_info'])}
                                        <span><s onclick="$(this).parent('span').remove()"></s>{$info['jifentprice_info']['title']}({$info['jifentprice_info']['toplimit']}积分)
                                        {if $info['jifentprice_info']['isopen']==0}<a class="cor_f00">[已关闭]</a>{/if}<input type="hidden" name="jifentprice_id" value="{$info['jifentprice_info']['id']}">
                                    </span>
                                        {/if}
                                    </div>
                                </div>
                            </li>
                        </ul>
                        <div class="line"></div>
                        <ul class="info-item-block">
                            <li>
                                <span class="item-hd item-title">促销数据</span>
                            </li>
                            <?php   $cfg_icon_rule = Model_Sysconfig::get_configs(0,array('cfg_icon_rule'));
                            $cfg_icon_rule = $cfg_icon_rule['cfg_icon_rule']; ?>
                            {if $cfg_icon_rule==1}
                            <li>
                                <span class="item-hd">图标设置{Common::get_help_icon('product_icon')}：</span>
                                <div class="item-bd">
                                    <a href="javascript:;" class="fl btn btn-primary radius size-S mt-3" onclick="Product.getIconNew(this,'.icon-sel')" title="选择">选择</a>
                                    <div class="save-value-div ml-10 icon-sel">
                                        {loop $info['iconlist_arr'] $k $v}
                                        <span class="mb-5 " title="{$v['kind']}" >
                                            <s onclick="$(this).parent('span').remove()"></s>{$v['kind']}
                                            <input type="hidden" class="lk" name="iconlist[]" value="{$v['id']}"/>
                                        </span>
                                        {/loop}
                                    </div>
                                </div>
                            </li>
                            {else}
                            <li>
                                <span class="item-hd">图标设置{Common::get_help_icon('product_icon')}：</span>
                                <div class="item-bd">
                                    <a href="javascript:;" class="fl btn btn-primary radius size-S mt-3" onclick="Product.getIcon(this,'.icon-sel')" title="选择">选择</a>
                                    <div class="save-value-div ml-10 icon-sel">
                                        {loop $info['iconlist_arr'] $k $v}
                                        <span class="mb-5"><s onclick="$(this).parent('span').remove()"></s><img src="{$v['picurl']}"><input type="hidden" name="iconlist[]" value="{$v['id']}"></span>
                                        {/loop}
                                    </div>
                                </div>
                            </li>
                            {/if}
                            <li>
                                <span class="item-hd">显示数据{Common::get_help_icon('product_virtual_data')}：</span>
                                <div class="item-bd">
                                  <span class="">
                                      <span class="item-text">推荐次数</span>
                                      <input type="text" name="recommendnum" id="yesjian" data-regrex="number" data-msg="*必须为数字" maxlength="6" class="input-text w80" value="{$info['recommendnum']}" />
                                  </span>
                                    <span class="ml-20">
                                      <span class="item-text">满意度</span>
                                      <input type="text" name="satisfyscore" id="satisfyscore" data-regrex="number" data-msg="*必须为数字" maxlength="3" class="input-text w80" value="{$info['satisfyscore']}"  />
                                  </span>
                                    <span class="ml-20">
                                      <span class="item-text">销量</span>
                                      <input type="text" name="bookcount" id="bookcount" data-regrex="number" data-msg="*必须为数字" maxlength="6" class="input-text w80" value="{$info['bookcount']}" />
                                  </span>
                                </div>
                            </li>
                        </ul>
                        <div class="line"></div>
                        <ul class="info-item-block">
                            <li>
                                <span class="item-hd item-title">预订信息</span>
                                <div class="item-bd">
                                    <div class="">
                                        <span class="item-text c-f60">开启多套餐预订后订票须知使用指定门票规则；多套餐预订不支持PC及老版H5；</span>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">多套餐预订{Common::get_help_icon('multiple_ticket_book')}：</span>
                                <div class="item-bd">
                                    <label class="radio-label"><input type="radio" name="is_open_multiple_ticket" value="0" {if empty($info['is_open_multiple_ticket']) || $info['is_open_multiple_ticket'] != 1}checked{/if}>关闭</label>
                                    <label class="radio-label ml-20"><input type="radio"  name="is_open_multiple_ticket" value="1" {if !empty($info['is_open_multiple_ticket']) || $info['is_open_multiple_ticket']==1}checked{/if}>开启</label>
                                </div>
                            </li>
                            <li class="refund-rule {if $info['is_open_multiple_ticket']!=1}hide{/if}">
                                <span class="item-hd">退订规则{Common::get_help_icon('multiple_rule_ticket_id')}：</span>
                                <div class="item-bd">
                                    <span class="select-box w200">
                                        <label>
                                            <select class="select" name="multiple_rule_ticket_id">
                                                {if !empty($tickets)}
                                                {loop $tickets $ticket}
                                                <option {if !empty($info['multiple_rule_ticket_id']) && $info['multiple_rule_ticket_id'] == $ticket['id']}selected{/if} value="{$ticket['id']}">{$ticket['title']}</option>
                                                {/loop}
                                                {else}
                                                <option value="">未设置套餐</option>
                                                {/if}
                                            </select>
                                        </label>
                                    </span>
                                </div>
                            </li>
                        </ul>
                        <div class="line"></div>
                        <ul class="info-item-block">
                            <li>
                                <span class="item-hd item-title">产品描述</span>
                            </li>
                            <li>
                                <span class="item-hd">预订须知：</span>
                                <div class="item-bd">
                                    {php Common::getEditor('booknotice',$info['booknotice'],1200,400);}
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">景点介绍：</span>
                                <div class="item-bd w800">
                                    {php Common::getEditor('content',$info['content'],1200,400);}
                                </div>
                            </li>
                            {loop $extended_data $v}
                            <li>
                                <span class="item-hd">{$v['chinesename']}：</span>
                                <div class="item-bd w800">
                                    {php Common::getEditor($v['columnname'],$v['content'],1200,400);}
                                </div>
                            </li>
                            {/loop}
                        </ul>
                    </div>
                    <!--基础信息结束-->

                    <!--价格库存开始-->
                    <div class="product-add-div mt-40" data-id="price_con">
                        <ul class="info-item-block">
                            <li>
                                <span class="item-hd item-title">预定模式</span>
                            </li>
                            <li>
                                <div class="item-bd alone-item-bd">
                                    <div class="item-block-radio active">
                                        <div class="left-radio">
                                            <input type="radio" checked/>
                                        </div>
                                        <div class="right-block">
                                            <div class="radio-title">需指定使用日期</div>
                                            <div class="radio-des">下单时用户需选择使用日期</div>
                                            <div class="radio-notice"><span class="c-999">适用于以下</span><span class="notice-text">场景</span></div>
                                        </div>
                                    </div>
                                </div>
                            </li>
                        </ul>
                        <div class="line"></div>

                        <!--人群设置-->
                        {include "admin/spot/edit/people"}
                        <!--人群设置-->

                        <div class="line"></div>

                        <!--套餐设置-->
                        {include "admin/spot/edit/suit"}
                        <!--套餐设置-->

                        <div class="line"></div>

                        <!--价格库存设置-->
                        {include "admin/spot/edit/price"}
                        <!--价格库存设置-->

                    </div>
                    <!--价格库存结束-->

                    <!--其他信息开始-->
                    <div class="product-add-div" data-id="other_info">
                        <ul class="info-item-block">
                            <li>
                                <span class="item-hd item-title">优化设置</span>
                            </li>
                            <li>
                                <span class="item-hd">优化标题{Common::get_help_icon('content_seotitle')}：</span>
                                <div class="item-bd">
                                    <input type="text" name="seotitle" id="seotitle" class="input-text w300" value="{$info['seotitle']}" >
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">Tag词{Common::get_help_icon('content_tagword')}：</span>
                                <div class="item-bd">
                                    <input type="text" id="tagword" name="tagword" class="input-text w300" value="{$info['tagword']}" >
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">关键词{Common::get_help_icon('content_keyword')}：</span>
                                <div class="item-bd">
                                    <input type="text" name="keyword" id="keyword" name="keyword" class="input-text w300" value="{$info['keyword']}">
                                </div>
                            </li>
                            <li>
                                <span class="item-hd">页面描述{Common::get_help_icon('content_description')}：</span>
                                <div class="item-bd">
                                    <textarea class="textarea w900"  name="description" id="description" cols="" rows="">{$info['description']}</textarea>
                                </div>
                            </li>
                        </ul>
                        <div class="line"></div>
                        <ul class="info-item-block">
                            <li>
                                <span class="item-hd item-title">模板信息</span>
                            </li>
                            <li>
                                <span class="item-hd">电脑端模板{Common::get_help_icon('product_template_set')}：</span>
                                <input type="hidden" name="templet" id="templet" value="{$info['templet']}"/>
                                <div class="item-bd" id="templet_list_pc"></div>
                            </li>
                            <li>
                                <span class="item-hd">移动端模板{Common::get_help_icon('product_template_set')}：</span>
                                <input type="hidden" name="wap_templet" id="wap_templet" value="{$info['wap_templet']}"/>
                                <div class="item-bd" id="templet_list_wap"></div>
                            </li>
                        </ul>
                    </div>
                    <!--其他信息结束-->
                    <div class="clear clearfix mt-5" style="height: 52px">
                        <input type="hidden" name="productid" id="productid" value="{$info['id']}"/>
                        <input type="hidden" name="action" id="action" value="{$action}"/>
                        <div class="pb-10 pt-10" style="position: fixed;bottom: 0;z-index: 1000;background: #fff;right: 0;left: 120px;border-top:1px solid #e5e5e5;">
                            <a class="btn btn-primary radius size-L ml-115" id="btn_save" href="javascript:;">保存</a>
                        </div>
                    </div>
                </form>
            </td>
        </tr>
    </table>

    <!--多套餐预订退订规则套餐选择-->
    <script type="text/html" id="multiple_ticket_template">
        {{if data.length > 0}}
        {{each data as value i}}
        <option {{if value.id == selected}}selected{{/if}} value="{{value.id}}">{{value.title}}</option>
        {{/each}}
        {{else}}
        <option value="">未设置套餐</option>
        {{/if}}
    </script>
</body>

<script type="application/javascript">
    //保存状态
    window.is_saving = 0;
    $(document).ready(function(){

        // 输入长度处理
        $(".text-number-con").on('keyup', '.input-text', function () {
            var val = $(this).val(),
                len = val.length;
            $(this).parent().find('.text-number .number').text(len);
        })

        // 多套餐预订开启切换
        $("input[name=is_open_multiple_ticket]").on('change', function (e) {
            var value = $(this).val();
            var obj = $(this);
            console.log(value);
            if(parseInt(value) === 1) {
                ST.Util.confirmBox('操作提示', '多套餐预订模式与分时预约不能同时使用，开启后将删除预约时段和报价，是否开启？',
                    function () {
                        var val = obj.val();
                        if(val==='1'){
                            $('.refund-rule').removeClass('hide');
                        }else{
                            $('.refund-rule').addClass('hide');
                        }
                    },
                    function () {
                    $("input[name=is_open_multiple_ticket]").eq(0).prop('checked', true);
                })
            }else{$('.refund-rule').addClass('hide');}
        })

        // 上传视频
        $('#uploadVideo').click(function(){
            // 上传方法
            $.upload({
                // 上传地址
                url: SITEURL+'uploader/video',
                // 文件域名字
                fileName: 'video',
                fileType: 'mp4',
                // 其他表单数据
                params: {uploadcookie:"<?php echo Cookie::get('username')?>"},
                // 上传完成后, 返回json, text
                dataType: 'json',
                // 上传之前回调,return true表示可继续上传
                onSend: function() {
                    return true;
                },
                // 上传之后回调
                onComplate: function(info) {
                    if(info.status){
                        $('#videoContent').html('<li><input name="product_video" type="hidden" value="'+info.data.path+'|'+info.data.name+'"><span class="v-name">'+info.data.name+'</span><a href="javascript:;" class="btn-link ml-20" onclick="videoNode()">删除</a></li>');
                    }
                }
            });

        });

        //导航切换
        $("#nav").find('span').click(function(){
            Product.changeTab(this,'.product-add-div');
        });
        $("#nav").find('span').eq(0).trigger('click');


        var action = "{$action}";
        //上传图片
        $('#pic_btn').click(function(){
            ST.Util.showBox('上传图片', SITEURL + 'image/insert_view', 0,0, null, null, document, {loadWindow: window, loadCallback: Insert});
            function Insert(result,bool){
                var len=result.data.length;
                for(var i=0;i<len;i++){
                    var temp =result.data[i].split('$$');
                    Imageup.genePic(temp[0],".up-list-div ul",".cover-div",temp[1]);
                }
            }
        })

        $("#product_frm input").st_readyvalidate();

        // 保存
        $("#btn_save").click(function(){
            //检测是否是在保存状态
            if(is_saving === 1){
                return false;
            }

            var checkRes = checkFormData();
            if(checkRes.status === false) {
                ST.Util.showFailureMsg(checkRes.msg);
                return false;
            }

            ST.Util.showLoading('保存中');
            $.ajaxform({
                url: SITEURL + "spot/admin/spot/ajax_save",
                method: "POST",
                form: "#product_frm",
                dataType: "JSON",
                success: function (res) {
                    if (res.status) {
                        ST.Util.showMsg('保存成功!', '4', 2000);
                        saveSuccess(res)
                    }
                    window.is_saving = 0;
                }
            });
        });

        function saveSuccess(res){
            var spotId = $("input[name=productid]").val(),
                title = $("input[name=title]").val();
            setTimeout(function () {
            if (!spotId && res.productid != null) {
                location.href = SITEURL+'spot/admin/spot/edit/{if isset($_GET['menuid'])}menuid/{$_GET['menuid']}/{/if}parentkey/product/itemid/4/id/'+ res.productid;
            } else {
                location.reload();
            }
            }, 1500)
        }

        // 保存前验证数据
        function checkFormData() {
            var result = {status: false, msg: ''};
            var spotName = $("#spotname").val();

            //验证名称
            if (spotName === '') {
                $("#nav").find('span').first().trigger('click');
                $("#spotname").focus();
                result.msg = '请填写景点名称';
                return result
            }

            // 检查人群选择
            var isDistPeople = $('input[name="is_dist_people"]:checked').val();
            isDistPeople = parseInt(isDistPeople)
            if (isDistPeople === 1) {
                var peopleGroup = $("input[name*=people_group]:checked");
                if (peopleGroup.length === 0) {
                    result.msg = '请至少维护一个人群';
                    return result;
                }
                var checkPeopleGroupStatus = true;
                // 检查人群数据填写
                peopleGroup.each(function (index, item) {
                    var checkPeopleGroupRes = checkPeopleGroup(item.value);
                    if(!checkPeopleGroupRes.status) {
                        result.msg = checkPeopleGroupRes.msg;
                        checkPeopleGroupStatus = false;
                        return false;
                    }
                })
                if(!checkPeopleGroupStatus) {
                    return result;
                }
            }

            // 检查规格选择
            var checkSkuStatus = true,
                suitSku = $('input[name*=suit_sku]:checked');

            suitSku.each(function (index, item) {
                if(item.value === 'period_time') {
                    var checkPeriodTimeRes = checkPeriodTime();
                    if(!checkPeriodTimeRes.status) {
                        result.msg = checkPeriodTimeRes.msg;
                        checkSkuStatus = false;
                        return false;
                    }
                }
            })

            if(!checkSkuStatus) {
                return result;
            }

            result.status = true;
            return result;
        }

        // 提交前检查人群填写
        function checkPeopleGroup(groupId) {
            var result = {status: false, msg: ''},
                groupObj = $(".people-group-con-" + groupId),
                checkObj = groupObj.find('input[name="people_age_type[' + groupId + ']"]:checked'),
                type = checkObj.val(),
                typeObj = $(".people-group-type-" + type + '-' + groupId),
                startAgeObj = typeObj.find('input[name="start_age[' + groupId + ']"]'),
                endAgeObj = typeObj.find('input[name="end_age[' + groupId + ']"]'),
                startAge = startAgeObj[0].value;

            if (startAge < 0  || startAge === '') {
                result.msg = '请填写开始年龄';
                return result;
            }

            startAge = parseInt(startAge);
            if (type === '2') {
                var endAge = endAgeObj[0].value;
                if (endAge < 0  || endAge === '') {
                    result.msg = '请填写结束年龄';
                    return result;
                }
                endAge = parseInt(endAge);
                if (startAge >= endAge) {
                    result.msg = '开始年龄需小于结束年龄';
                    return result;
                }
            }

            result.status = true;
            return result;
        }

        // 提交前检查场次选择
        function checkPeriodTime() {
            var result = {status: false, msg: ''},
                periodTimeObj = $("input[name=period_time]:checked");

            if(periodTimeObj.length === 0){
                result.msg = '请至少选择一个场次';
                return result;
            }

            result.status = true;
            return result;
        }

        //如果是修改页面
        {if $action=='edit'}

        var attrlist = ST.Modify.getSelectAttr({$info['attrlist_arr']});
        var piclist = ST.Modify.getUploadFile({$info['piclist_arr']});

        $(".attr-sel").html(attrlist);
        $(".pic-sel").html(piclist);
        var litpic = $("#litpic").val();
        $(".img-li").find('img').each(function(i,item){
            if($(item).attr('src')==litpic){
                var obj = $(item).parents('.img-li').first().find('.btn-ste')[0];
                Imageup.setHead(obj,i+1);
            }
        });
        window.image_index= $(".pic-sel").find('li').length;//已添加的图片数量
        {/if}
        });

        function videoNode(_this){
            $('#videoContent').html('');
        }
</script>

<script type="application/javascript">
    //模板相关
    $(document).ready(function(){
        ajax_get_template();
        //获取可用模板
        function ajax_get_template() {
            var webid = $('select[name=webid]').val();
            var template = "{$info['templet']}";
            var wap_templet = "{$info['wap_templet']}";
            $.ajax({
                type:'post',
                dataType:'json',
                url:SITEURL+'spot/admin/spot/ajax_get_template_list',
                data:{page:'spot_show',webid:webid},
                success:function (data) {
                    if(data.pclist.length>0)
                    {
                        var pchtml = '';
                        $(data.pclist).each(function (i,v) {
                            var itemclass = 'label-module-item';
                            if ((!template || template=='line_show.htm') && v.isuse == 1)
                            {
                                itemclass = 'label-module-cur-item';
                            }
                            else if (template == v.pagepath)
                            {
                                itemclass = 'label-module-cur-item';
                            }
                            pchtml += '<a  class="'+itemclass+' mr-5"  href="javascript:void(0)" data-type="templet" data-value="'+v.pagepath+'" onclick="setTemplet(this)">'+v.title+'</a>';
                        });
                        $('#templet_list_pc').html(pchtml);
                    }
                    if(data.waplist.length>0)
                    {
                        var waphtml = '';
                        $(data.waplist).each(function (i,v) {
                            var itemclass = 'label-module-item';

                            if (wap_templet == v.pagepath)
                            {
                                itemclass = 'label-module-cur-item';
                            }
                            waphtml += '<a  class="'+itemclass+' mr-5"  href="javascript:void(0)" data-type="wap_templet" data-value="'+v.pagepath+'" onclick="setTemplet(this)">'+v.title+'</a>';
                        });
                        $('#templet_list_wap').html(waphtml);
                    }
                }

            })
        }
    });

    //设置模板
    function setTemplet(obj)
    {
        var templet = $(obj).data('value');
        var select = $(obj).data('type');
        $(obj).parent().find('a').removeClass('label-module-cur-item');
        $(obj).parent().find('a').addClass('label-module-item');
        $(obj).addClass('label-module-cur-item');
        $(obj).removeClass('label-module-item');
        $("#"+select).val(templet);
    }
</script>
</html>
